﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

using System.Data;

/// <summary>
/// WebService2 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
// [System.Web.Script.Services.ScriptService]
public class WebService2 : System.Web.Services.WebService {

    public WebService2 () {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    MsSqlHelper mssql = new MsSqlHelper();
    Common Init = new Common();

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

    [WebMethod]
    public void Datainspection(int pageSize, int pagination)
    {
        try
        {
            Context.Response.ContentType = "text/plain";
            DataSet ds = new DataSet();
            ds = mssql.ExecuteDs("select top " + pageSize + " * from("
+ "select ROW_NUMBER() OVER (ORDER BY a.imageid desc) AS RowNumber,a.detailid,rtrim(b.spmch) as GoodsName,rtrim(b.shpgg) as Spec,rtrim(b.dw) as Unit,"
+ "rtrim(b.shengccj) as FactoryName,rtrim(b.pizhwh) as Fileno,fzxx1 as Serial,'http://khoa.scjrm.com:86'+a.url as url"
+ " from imagedoc a(nolock),spkfk b(nolock) where a.detailid=b.spid and a.leibie='检验报告') as A"
+ " WHERE RowNumber > " + pageSize + "*" + pagination + "  order by RowNumber");
            string result = Init.dsToJson(ds);
            Context.Response.Write(result);
        }
        catch (Exception ex)
        {
            Init.WriteLog(ex.ToString(), true);
            return;
        }
    }
    
}
